package com.nullpointer.Login;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Page2 extends Activity implements OnClickListener{
	Button Gooo,Exit,Back;
	EditText gt1,gt2,gt3;
	TextView vt1,vt2,vt3;
	String to,subject,body;
	SingleTon dbh;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.page);
		Gooo=(Button) findViewById(R.id.buttontt);
		Exit=(Button) findViewById(R.id.exit);
		Back=(Button) findViewById(R.id.back);
		
		gt1=(EditText) findViewById(R.id.ett1);
		gt2=(EditText) findViewById(R.id.ett2);
		gt3=(EditText) findViewById(R.id.ett3);
		
		vt1=(TextView) findViewById(R.id.rt1);
		vt2=(TextView) findViewById(R.id.rt2);
		vt3=(TextView) findViewById(R.id.rt3);
		
		Gooo.setOnClickListener(this);
		
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub
		to 		= gt1.getText().toString();
		subject = gt2.getText().toString();
		body	= gt3.getText().toString();
		if(v==Gooo){
			 try {   
	             GMailSender sender = new GMailSender(dbh.gets1(), dbh.gets2());
	             sender.sendMail(subject,body,"kaustubhmalgaonkar@gmail.com",to);  
	             Toast.makeText(getBaseContext(), "succeed to:"+gt1.getText().toString(), Toast.LENGTH_LONG).show();
	         } catch (Exception e) {   
	             Log.e("SendMail", e.getMessage(), e);   
	         }
			 if(v==Back){
				 Intent i= new Intent(this,Login.class);
				 startActivity(i)
;			 }
			 if(v==Exit){
				 finish();
			 }
			 
		}
		
		
	}
	

}
